pub fn goldbach_conjecture() -> u64 {
    let mut count = 0;
    let mut ans = vec![];
    let mut sum = 0;
    let (is_primes, odd_composite_vec) = prime_vec(10000);
    for odd_composite_num in odd_composite_vec.iter() {
        let mut found = false;
        for (idx, prime) in is_primes.iter().enumerate() {
            if *prime {
                if idx > *odd_composite_num {
                    break;
                }
                let diff = odd_composite_num - idx;
                let mut n = 1;
                while n * n * 2 <= diff {
                    if n * n * 2 == diff {
                        found = true;
                        break;
                    }
                    n += 1;
                }
            }
            if found {
                break;
            }
        }

        if !found {
            count += 1;
            sum += odd_composite_num;
            ans.push(odd_composite_num);
        }
        if count == 2 {
            return sum.try_into().unwrap();
        }
    }

    unreachable!();
}
//找出小于n的所有素数和奇合数
fn prime_vec(n: usize) -> (Vec<bool>, Vec<usize>) {
    let mut odd_composite_vec = vec![];
    let mut is_primes = vec![true; n + 1];
    // 0 和 1 不是素数
    is_primes[0] = false;
    is_primes[1] = false;
    let mut primes = vec![];
    for i in 2..=n {
        if is_primes[i] {
            primes.push(i);
        } else if i % 2 != 0 {
            odd_composite_vec.push(i);
        }

        let mut j = 0;
        while j < primes.len() && i * primes[j] <= n {
            let num = i * primes[j];
            is_primes[num] = false;
            if i % primes[j] == 0 {
                break;
            }
            j += 1;
        }
    }

    (is_primes, odd_composite_vec)
}
